'''
Created on Jan 30, 2012

@author: onetera
'''

class Singleton:
    def __init__(self, decorated): 
        self._decorated = decorated
    
    def Instance(self):
        try:
            return self._decorated
        except AttributeError:
            self._instance = self._decorated()
            return self._instance
    def __call__(self):
        raise TypeError( 'This is a Singleton')
    
    
@Singleton 
class Foo: 
    def __init__(self): 
        print 'Foo created' 

Foo = Singleton(Foo) 